ATOM Documentation

โ† Back to App

Sales Hub Testing Guide

๐Ÿš€ Quick Start

1. Access the Dashboard

**Development:**

http://localhost:3000/dashboards/sales

**Production:**

https://atom-saas.fly.dev/dashboards/sales

2. Test Data Overview

The seed script created:

  • **Tenant ID**: demo_tenant
  • **3 Leads**: ceo@growthcorp.com, marketing@startup.io, competitor@rival.com
  • **4 Deals**:
  • Enterprise License - GrowthCorp ($120,000, Negotiation)
  • Global Rollout - TechSystems ($250,000, Proposal) - **Stalled for 20 days**
  • Team Expansion - StartupIO ($45,000, Qualification)
  • Security Upgrade - FinanceCorp ($85,000, Discovery) - **Stalled for 30 days**

---

๐Ÿงช API Testing

Test 1: Dashboard Stats

**Endpoint:** GET /api/sales/dashboard/stats

**Expected Response:**

{
  "total_pipeline": 500000,
  "active_deals_count": 4,
  "key_contacts": 0,
  "win_rate": 0,
  "weighted_forecast": 212500,
  "deals_by_stage": {
    "discovery": 1,
    "qualification": 1,
    "proposal": 1,
    "negotiation": 1
  }
}

**Test Command:**

curl https://atom-saas.fly.dev/api/sales/dashboard/stats | jq '.'

---

Test 2: AI Insights

**Endpoint:** GET /api/sales/insights

**Expected Response:**

{
  "status": "success",
  "count": 2,
  "insights": [
    {
      "anomaly_id": "stalled_deal_[id]",
      "severity": "warning",
      "title": "Deal 'Global Rollout - TechSystems' stalled for 20 days",
      "description": "Deal worth $250,000 hasn't moved in 20 days",
      "recommendation": "Send follow-up email or schedule call to re-engage",
      "action_type": "email"
    },
    {
      "anomaly_id": "stalled_deal_[id]",
      "severity": "critical",
      "title": "Deal 'Security Upgrade - FinanceCorp' stalled for 30 days",
      "description": "Deal worth $85,000 hasn't moved in 30 days",
      "recommendation": "Send follow-up email or schedule call to re-engage",
      "action_type": "email"
    }
  ]
}

**Test Command:**

curl https://atom-saas.fly.dev/api/sales/insights | jq '.insights[] | {severity, title, description}'

---

Test 3: Sales Activities

**Endpoint:** GET /api/sales/activities?limit=10

**Expected Response:**

{
  "status": "success",
  "activities": [
    {
      "id": "[activity_id]",
      "type": "created",
      "description": "Deal 'Enterprise License - GrowthCorp' created worth $120,000",
      "deal_id": "[deal_id]",
      "deal_name": "Enterprise License - GrowthCorp",
      "deal_value": 120000,
      "timestamp": "2025-03-06T..."
    }
  ],
  "total_count": 4
}

**Test Command:**

curl https://atom-saas.fly.dev/api/sales/activities?limit=10 | jq '.activities[] | {type, description, deal_name}'

---

Test 4: Revenue Forecast

**Endpoint:** GET /api/sales/forecast?months=3

**Expected Response:**

{
  "status": "success",
  "forecast": [
    {
      "month": "March 2025",
      "weighted_forecast": 0,
      "best_case": 0,
      "worst_case": 0,
      "deal_count": 0,
      "confidence": 0
    }
  ],
  "summary": {
    "total_weighted_forecast": 0,
    "total_best_case": 0,
    "total_worst_case": 0,
    "total_deals": 0,
    "avg_confidence": 0
  }
}

**Test Command:**

curl https://atom-saas.fly.dev/api/sales/forecast?months=3 | jq '.'

---

Test 5: Pipeline

**Endpoint:** GET /api/sales/pipeline

**Expected Response:**

[
  {
    "deal": "Enterprise License - GrowthCorp",
    "value": 120000,
    "status": "negotiation",
    "platform": "salesforce",
    "company": "GrowthCorp"
  },
  {
    "deal": "Global Rollout - TechSystems",
    "value": 250000,
    "status": "proposal",
    "platform": "hubspot",
    "company": "TechSystems"
  }
]

**Test Command:**

curl https://atom-saas.fly.dev/api/sales/pipeline | jq '.[] | {deal, value, status, company}'

---

๐ŸŽจ Frontend Testing

1. Visual Inspection

Navigate to /dashboards/sales and verify:

**Dashboard Metrics:**

  • โœ… Total Pipeline: $500.0k
  • โœ… Active Deals: 4
  • โœ… Win Rate: 0% (no closed deals yet)
  • โœ… All cards show data, not zeros

**Deals Table:**

  • โœ… Shows 4 deals
  • โœ… Values are correct
  • โœ… Stages are displayed
  • โœ… Platform badges shown

**AI Insights Panel:**

  • โœ… Shows 2 stalled deal warnings
  • โœ… One warning (20 days)
  • โœ… One critical (30 days)
  • โœ… Action buttons visible

**Activity Feed:**

  • โœ… Shows 4 activities
  • โœ… Deal creation logs visible
  • โœ… Timestamps correct

**Revenue Forecast:**

  • โœ… Shows 3 months
  • โœ… Confidence bars visible
  • โœ… Deal counts displayed

---

๐Ÿ“Š Database Verification

Connect to Database

# Using psql
psql $DATABASE_URL

# Or using Python
cd backend-saas
python -c "
from core.database import SessionLocal
from core.models import Deal, Lead, SalesActivity
db = SessionLocal()
print(f'Deals: {db.query(Deal).count()}')
print(f'Leads: {db.query(Lead).count()}')
print(f'Activities: {db.query(SalesActivity).count()}')
"

Verify Data

**Check Deals:**

SELECT name, value, stage, probability, updated_at
FROM deals
WHERE tenant_id = 'demo_tenant'
ORDER BY updated_at DESC;

**Check Insights:**

SELECT name, value, stage,
       EXTRACT(DAY FROM (NOW() - updated_at)) as days_stalled
FROM deals
WHERE tenant_id = 'demo_tenant'
  AND updated_at < NOW() - INTERVAL '14 days';

---

๐Ÿ› Troubleshooting

Issue: "No data showing"

**Solution:**

  1. Check browser console for API errors
  2. Verify tenant_id is correct
  3. Check network tab in browser DevTools
  4. Run: curl https://atom-saas.fly.dev/api/sales/dashboard/stats

Issue: "Insights not loading"

**Solution:**

  1. Verify deals have updated_at timestamps
  2. Check backend logs: fly logs -a atom-saas --tail 100
  3. Ensure deals exist in database
  4. Test insights endpoint directly

Issue: "Activities not showing"

**Solution:**

  1. Check sales_activities table
  2. Verify tenant_id matches
  3. Check SalesActivityService logs
  4. Test activities endpoint directly

Issue: "Forecast shows 0"

**Solution:**

  1. Ensure deals have expected_close_date set
  2. Check probability values are set
  3. Verify deals are in active stages
  4. Test forecast endpoint directly

---

โœ… Testing Checklist

  • [ ] Dashboard loads without errors
  • [ ] All metric cards show correct values
  • [ ] Deals table displays all 4 test deals
  • [ ] AI Insights panel shows stalled deal warnings
  • [ ] Activity feed shows creation logs
  • [ ] Revenue forecast displays 3 months
  • [ ] Refresh button works
  • [ ] No console errors in browser
  • [ ] API endpoints return correct data
  • [ ] Multi-tenant isolation works (only see your data)

---

๐Ÿ” Debug Mode

Enable Debug Logging

**Backend:**

# In backend-saas/sales/routes.py
import logging
logging.basicConfig(level=logging.DEBUG)

**Frontend:**

// In browser console
localStorage.setItem('debug', 'true');

Check WebSocket Connection

// In browser console
const ws = new WebSocket('wss://atom-saas.fly.dev/ws');
ws.onopen = () => console.log('โœ… WebSocket connected');
ws.onerror = (error) => console.error('โŒ WebSocket error:', error);

---

๐Ÿ“ˆ Performance Testing

Load Test

# Install hey
go install github.com/rakyll/hey@latest

# Test dashboard stats endpoint
hey -n 100 -c 10 https://atom-saas.fly.dev/api/sales/dashboard/stats

# Test insights endpoint
hey -n 100 -c 10 https://atom-saas.fly.dev/api/sales/insights

Monitor Response Times

# Test all endpoints
for endpoint in "dashboard/stats" "insights" "activities?limit=10" "forecast?months=3" "pipeline"; do
  echo "Testing /api/sales/$endpoint"
  time curl -s "https://atom-saas.fly.dev/api/sales/$endpoint" > /dev/null
  echo ""
done

---

๐ŸŽฏ Expected Results

After running all tests, you should see:

  1. **Dashboard Metrics**: Total pipeline of $500k, 4 active deals
  2. **AI Insights**: 2 stalled deal warnings (1 warning, 1 critical)
  3. **Activities**: 4 deal creation activities
  4. **Forecast**: 3-month forecast with 0 confidence (no close dates set)
  5. **Pipeline**: 4 deals with correct stages and values

---

๐Ÿ“ž Support

If you encounter issues:

  1. Check backend logs: fly logs -a atom-saas --tail 100
  2. Check database: Connect via psql or Neon console
  3. Check audit logs: SELECT * FROM saas_audit_logs ORDER BY timestamp DESC LIMIT 20;
  4. Review browser console and network tab

---

**Last Updated:** March 6, 2025

**Status:** โœ… Ready for Testing